home *** CD-ROM | disk | FTP | other *** search
Text File | 2000-06-10 | 1.5 KB | 63 lines | [TEXT/R*ch] |
- # Kent Sorensen 06/09/00 This file contains an alias useful in online role playing games etc.
-
- # /dice "number of dice" "number of sides" "modifier"
-
- # in script : $0 : number of dice
- # : $1 : number of sides
- # : $2 : modifier
-
- # output examples
- # /dice 2 6 0
- # <yournick> rolls 2 d 6 = 3,3 = 6
-
- # /dice 2 6 10
- # <yournick> rolls 2 d 6 + 10 = 3,1 + 10 = 14
-
- # A "gotcha" of the ircII language is that if you use the @ form instead of the
- # assign command, the parameters have no $ making it just 0 instead of $0
-
- # use the @ form when you use the variable is an arithmetic expression like
- # this @eyes = eyes + 1
-
- # the [] around some elements cause them to be 'evaluated' meaning that
- # the contents of variables are used instead of the name of the variable
-
- alias dice {
- ^assign dices $0
-
- # get a random number between zero and one less than $1
- ^assign eyes $rand($1)
-
- # compensate for the zero base
- @eyes = eyes + 1
-
- # create output string and treat as string, not number
- ^assign outputString ${eyes}
- @outputSum = eyes + [$2]
-
-
- # the first dice was handled above, deal with the rest and build comma separated list
-
- ^assign repcnt $0
- while ( repcnt > 1 )
- {
- ^assign eyes $rand($1)
- @eyes = eyes + 1
-
- # concatenate output string as string, not number
- ^assign outputString $outputString,${eyes}
- @outputSum = outputSum + eyes
-
- @repcnt = repcnt - 1
- }
- ^assign -repcnt
-
- if ([$2] > 0)
- {
- me rolls $0 d $1 + $2 = $outputString + $2 = $outputSum
- }
- {
- me rolls $0 d $1 = $outputString = $outputSum
- }
- }
-